package com.beney.ds.sorting;

import com.beney.ds.sorting.abs.AbstractSort;

public class BubbleSort extends AbstractSort {
    private BubbleSort() {
    }

    public static void sort(Comparable[] arr) {
        if (arr == null) return;
        int len = arr.length;
        for (int i = 1; i < len; ++i) {
            for (int j = 0; j < len - i; ++j) {
                if (arr[j].compareTo(arr[j + 1]) > 0) {
                    swap(arr, j, j + 1);
                }
            }
        }
    }
}
